--[[
测试 repeated字段
]]
require "Buffer"
--require "Person"
--require "Phone"
require "PBCode"

--[[
local f = io.open("test2.bin", "rb")
local t = f:read("*all")
local msg = {}
SetIndex(msg, Phone)

msg:Parse(CreateBuffer(t))
DumpPB(msg)
]]

--[[
local f = io.open("test3.bin", "rb")
local t = f:read("*all")
local b = os.clock()
for i = 1, 100000 do
	local msg = {}
	SetIndex(msg, Person)
	msg:Parse(CreateBuffer(t))
end

local ed = os.clock()

print("Cost", ed-b)
]]
--DumpPB(msg)


local f = io.open("test3.bin", "rb")
local t = f:read("*all")

local msg = {}
SetIndex(msg, Person)
msg:Parse(CreateBuffer(t))

local b = os.clock()
for i = 1, 100000 do
	local buf = msg:Serialize()
	local s = buf:Finish()
	--print(s)
end

local ed = os.clock()

print("Cost", ed-b)


--[[
local buf = msg:Serialize()
local ret = buf:Finish()
local f1 = io.open("out3.bin", "wb")
f1:write(ret)
f1:close()
]]